<template>
  <div>
    <p v-if="!repoName">loading......</p>
    <p v-else>most star repo is <a :href="repoUrl">{{ repoName }}</a></p>
  </div>
</template>

<script>

import axios from 'axios'

export default {

  name: "App",
  components: {},
  data() {
    return {
      repoUrl: '',
      repoName: ''
    }
  },
  mounted() {
    axios.get('https://api.github.com/search/repositories?q=v&sort=stars')
      .then(response => {
          const result = response.data
          this.repoName = result.items[0].name
          this.repoUrl = result.items[0].html_url

        }
      ).catch(error => {
      console.log(error)
      alert('请求失败')
    })

  }



}
</script>

<style scoped>


</style>
